/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 *//*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 *//*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 *//*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package poker_sim;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import javax.swing.JPanel;
import javax.swing.Timer;

/**
 *
 * @author Rob
 */
public class CardViewer extends JPanel
{
    //width Of image 949
    //height of image 391
    BufferedImage[] Skin = new BufferedImage[5];
    Timer timer;
    //DeckFactory DF = new DeckFactory();
    int Location = -1;
    //Checksums for the animation
    int CurrentX = 1;
    int IncreamentX = 73;
    //End checksums for the animation
    
    
    public CardViewer()
    {
        
        //this.setBackground(Color.red);
    }
    
    public void LoadCard(BufferedImage crd)
    {
        Location++;
        Skin[Location] = crd;
        this.revalidate();
        this.repaint();
        
    }
    
    public void Reset()
    {
        this.setBackground(Color.getColor("240,240,240"));
        Skin = null;
        Skin = new BufferedImage[5];
        Location = -1;
        this.revalidate();
        this.repaint();
        
    }
    
    @Override
    public void paint(Graphics G)
    {
        //user the normal paint function, if nor used, artifacts will show
        //Skin = DF.getDeck().drawCard().IMG;
        super.paint(G);
        if(Skin != null)
        {

            Graphics2D G2 = (Graphics2D)G;
            G2.setBackground(Color.yellow);
            AffineTransform D = new AffineTransform();
            D.setToScale(1, 1);
            for( int i = 0; i <= Location; i++)
            {
                G2.drawImage(Skin[i], null, i * IncreamentX, 0);
            }
            
            //G2.drawRenderedImage(Skin, D);
            
        }
        

    }
}
